body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(45deg, #cfffd0, #3fff46);
}

.square {
  position: relative;
  width: 100px;
  height: 100px;
  animation: rotate 8s linear infinite;
  border: 10px dashed rgba(0, 0, 0, .2);
  box-shadow: 0 0 0 10px rgba(0, 0, 0, .5),
        inset 0 0 0 10px rgba(0, 0, 0, .4);
}

@keyframes rotate {
  0% {
    transform: rotate(360deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.square span {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

.square span::before{
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border: none;
  border-top: 10px solid #fff;
  animation: animate 2s linear infinite;
}

@keyframes animate {
  0% {
    left: -100%;
  }
  25% {
    left: 0;
  }
  50%, 100% {
    left: 100%;
  }
}

.square span:nth-child(1){
  transform: rotate(0deg);
}

.square span:nth-child(2){
  transform: rotate(90deg);
}

.square span:nth-child(3){
  transform: rotate(180deg);
}

.square span:nth-child(4){
  transform: rotate(270deg);
}

.square span:nth-child(1):before {
  animation-delay: 0s;
}

.square span:nth-child(2):before {
  animation-delay: 0.5s;
}

.square span:nth-child(3):before {
  animation-delay: 1s;
}

.square span:nth-child(4):before {
  animation-delay: 1.5s;
}
